<%-- 
    Document   : index
    Created on : Dec 13, 2009, 5:46:44 PM
    Author     : Jeremy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="jhu.profiteer.data.Location" %>
<%@ page import="jhu.profiteer.data.LocationJpaController" %>
<%@ page import="jhu.profiteer.data.Character" %>
<%@ page import="jhu.profiteer.data.CharacterJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Current Commodity Values";
    String cssFile = "/profiteer-game/css/profiteer.css";
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <%
                  LocationJpaController ljc = new LocationJpaController();
                  CharacterJpaController cjc = new CharacterJpaController();
                  List<Location> locations = ljc.findLocationEntities();
                  List<Character> characters = cjc.findCharacterEntities();

                  if(0 == locations.size())
                  {
                %>
                  <p>There are no locations available!</p>
                <%
                  }
                  else if(0 == characters.size())
                  {
                %>
                  <p>There are no characters available!</p>
                <%
                  }
                  else
                  {
                %>
                  <form action="processCCV" method="post">
                    <table>
                      <tr>
                        <td>
                          <select name="locationId">
                            <%
                              for(Location l : locations)
                              {
                            %>
                            <option value="<%= l.getId() %>"><%= l.getName() %></option>
                            <%
                              }
                            %>
                          </select>
                        </td>
                        <td>
                          <select name="characterId">
                            <%
                              for(Character c : characters)
                              {
                            %>
                            <option value="<%= c.getId() %>"><%= c.getName() %></option>
                            <%
                              }
                            %>
                          </select>
                        </td>
                        <td><input type="submit" name="submit" value="View Current Commodity Values" /></td>
                        <td><input type="submit" name="submit" value="Generate Current Commodity Values" /></td>
                      </tr>
                    </table>
                  </form>
                <%
                  }
                %>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>
